package org.spiderflow.core.expression.parsing.ast.literal;

import org.spiderflow.core.expression.ExpressionTemplate;
import org.spiderflow.core.expression.ExpressionTemplateContext;
import org.spiderflow.core.expression.parsing.Span;
import org.spiderflow.core.expression.parsing.ast.Expression;

import java.io.IOException;

/**
 * A boolean literal, with the values <code>true</code> and <code>false</code>
 *
 * @author zsh
 */
public class BooleanLiteral extends Expression {
    private final Boolean value;

    public BooleanLiteral(Span literal) {
        super(literal);
        this.value = Boolean.parseBoolean(literal.getText());
    }

    public Boolean getValue() {
        return value;
    }

    @Override
    public Object evaluate(ExpressionTemplate template, ExpressionTemplateContext context) throws IOException {
        return value;
    }
}